/* 
 * Copyright 2011 Carnegie Mellon University
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package edu.cmu.lti.dimple.data;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 * Loads MS paraphrase data. 
 * 
 * @author Hideki Shima
 *
 */
public class MSParaphrasePairLoader {

  public static List<MSParaphrasePair> load(File f) {
    List<MSParaphrasePair> list = new ArrayList<MSParaphrasePair>();
    try {
      FileInputStream fis = new FileInputStream(f);
      InputStreamReader isr = new InputStreamReader(fis, "utf-8");
      BufferedReader br = new BufferedReader(isr);
      String line = null;
      while ( (line=br.readLine())!=null ) {
        String[] values = line.split("\t");
        if ( values.length<=1) continue;
        list.add( new MSParaphrasePair(values[0], values[1], values[2], values[3], values[4]) );
      }
      br.close();
      isr.close();
      fis.close();
      
    } catch (Exception e) {
      e.printStackTrace();
    }
    return list;
  }
}
